<div class="main-content" ng-controller="TaskDetailController">
  <div class="help-container" ng-if="noSuchTask" auto-height ng-cloak>
    <div>
      <div class="help-text wide">
        <div ng-if="noSuchTask" class="description">
          {{ 'TASK.MESSAGE.NO-SUCH-TASK-HELP' | translate }}
        </div>
        <div class="help-entry" ng-click="returnToTaskList(); $event.stopPropagation();">
          <span class="glyphicon glyphicon-arrow-left"></span>
          <span translate="TASK.MESSAGE.NO-SUCH-TASK-RETURN-TO-LIST"></span>
        </div>
      </div>
    </div>
  </div>
  <!-- 无表单时按钮 -->
  <div
    class="help-container"
    ng-if="!model.task && !model.loading && state.noOwnTasks && !noSuchTask"
    auto-height
    ng-cloak
  >
    <div>
      <div class="help-text wide">
        <div ng-if="state.noOwnTasks" class="description">
          {{ 'TASK.MESSAGE.NO-TASKS-HELP' | translate }}
        </div>
        <div
          class="help-entry toggle-create-task"
          ng-class="{'active': newTask.inline }"
          ng-click="createTaskInline()"
          ng-show="!newProcessInstance.inline"
        >
          <span class="glyphicon glyphicon-plus-sign"></span>
          <span translate="TASK.MESSAGE.NO-TASKS-CREATE-TASK"></span>
          <div ng-if="newTask.inline" class="clearfix" style="padding: 5px;">
            <div class="form-group">
              <label translate="TASK.FIELD.NAME"></label>
              <input
                type="text"
                class="form-control"
                ng-model="newTask.name"
                ng-placeholder="Name"
                auto-focus="newTask.inline"
                select-text="newTask.name"
                ng-disabled="newTask.loading"
                custom-keys
                enter-pressed="confirmTaskCreation(newTask)"
              />
            </div>
            <div class="form-group">
              <label translate="TASK.FIELD.DESCRIPTION"></label>
              <textarea
                class="form-control"
                rows="2"
                id="add-comment-input"
                ng-model="newTask.description"
                ng-disabled="newTask.loading"
              ></textarea>
            </div>
            <div class="pull-right">
              <button
                class="btn btn-xs"
                ng-click="cancelTaskCreation(); closeInlineTaskCreation($event);"
                ng-disabled="newTask.loading"
                translate="GENERAL.ACTION.CANCEL"
                tabindex="-1"
              ></button>
              <button
                class="btn btn-xs"
                ng-click="confirmTaskCreation(newTask); closeInlineTaskCreation($event);"
                ng-disabled="!newTask.name || newTask.name.length == 0 || newTask.loading"
                translate="TASK.ACTION.CREATE-CONFIRM"
              ></button>
            </div>
          </div>
        </div>
        <div
          class="help-entry"
          ng-click="createProcess(); $event.stopPropagation();"
          ng-show="!newTask.inline"
          ng-class="{'active': newProcessInstance.inline }"
        >
          <span class="glyphicon glyphicon-plus-sign"></span>
          <span translate="TASK.MESSAGE.NO-TASKS-CREATE-PROCESS"></span>
        </div>
      </div>
    </div>
  </div>

  <div class="content clearfix scroll-container" auto-height offset="6" ng-if="model.task && !noSuchTask">
    <div
      class="top-buttons"
      style="left:41px"
      ng-if="!(activeTab == 'form' && model.formData != null && model.formData != undefined)"
    >
      <div class="btn-group pull-right" ng-if="!rev">
        <div class="btn-toolbar pull-right">
          <button title="关闭窗口" class="btn btn-inverse" ng-click="closeModelWindow()">
            <i class="toolbar-button ng-scope glyphicon glyphicon-remove" data-toggle="tooltip" title="关闭窗口"></i>
          </button>
        </div>
      </div>
      <button
        id="form_show_chart_button"
        class="btn btn-default"
        ng-click="showFlowChart()"
        translate="FORM.ACTION.FLOW-CHART"
      ></button>
      <button
        id="form_show_history_button"
        class="btn btn-default"
        ng-click="showApproveHistory()"
        translate="FORM.ACTION.APPROVE-HISTORY"
      ></button>
      <button class="btn btn-default" ng-click="showPrint()" translate="FORM.ACTION.FORM-PRINT"></button>
    </div>
    <!-- FORM -->
    <h3 class="start-title"><form-title style="top:50px;" value="model.processInstance.name"></form-title></h3>
    <div class="section" ng-show="activeTab == 'form' && model.formData != null && model.formData != undefined">
      <!-- unclaimed task-->
      <div
        ng-if="(model.task.assignee == null || model.task.assignee == undefined) && (!model.task.memberOfCandidateGroup && !model.task.memberOfCandidateUsers && !(model.task.initiatorCanCompleteTask && model.task.processInstanceStartUserId == ('' + account.id)))"
      >
        <activiti-form
          form-definition="model.formData"
          task-id="model.task.id"
          ng-if="model.formData"
          disable-form="model.task.assignee == null || model.task.assignee == undefined"
          hide-buttons="model.task.endDate"
          disable-form-text="'TASK.MESSAGE.CLAIM-TASK-FIRST'"
          rev="rev"
        >
        </activiti-form>
      </div>

      <!-- task with assignee -->
      <div
        ng-if="(model.task.assignee && model.task.assignee.id != undefined && model.task.assignee.id != null && model.task.assignee.id != undefined) 
            || ((model.task.assignee == null || model.task.assignee == undefined) && (model.task.memberOfCandidateGroup || model.task.memberOfCandidateUsers || (model.task.initiatorCanCompleteTask && model.task.processInstanceStartUserId == ('' + account.id))))"
      >
        <activiti-form
          form-definition="model.formData"
          task-id="model.task.id"
          ng-if="model.formData"
          is-cancel="false"
          can-save="false"
          can-urge="false"
          hide-buttons="true"
          is-pass="true"
        >
        </activiti-form>
      </div>
    </div>

    <!-- 处理无表单有和无assignee的情况 -->
    <div ng-show="activeTab == 'details' && hasDetails() == true">
      <div
        ng-show="model.task.assignee || (model.task.assignee == null || model.task.assignee == undefined) && (model.task.memberOfCandidateGroup || model.task.memberOfCandidateUsers || (model.task.initiatorCanCompleteTask && model.task.processInstanceStartUserId == ('' + account.id)))"
        class="no-form"
      >
        {{ 'PROCESS.MESSAGE.NO-FORM-PROCESS' | translate }}
      </div>
      <div
        class="section"
        ng-if="(model.task.assignee == null || model.task.assignee == undefined) && (!model.task.memberOfCandidateGroup && !model.task.memberOfCandidateUsers && !(model.task.initiatorCanCompleteTask && model.task.processInstanceStartUserId == ('' + account.id)))"
      >
        <div class="top-buttons" ng-if="taskId && !rev" ng-controller="RenderFormController">
          <div class="btn-group pull-right">
            <div class="btn-toolbar pull-right">
              <button title="关闭窗口" class="btn btn-inverse" ng-click="closeModelWindow()">
                <i
                  class="toolbar-button ng-scope glyphicon glyphicon-remove"
                  data-toggle="tooltip"
                  title="关闭窗口"
                ></i>
              </button>
            </div>
          </div>
        </div>
        <!-- 流程实例详情关闭按钮 -->
        <div class="top-buttons" ng-if="rev" ng-controller="TaskDetailController">
          <div class="btn-toolbar pull-right">
            <button title="关闭窗口" class="btn btn-inverse" ng-click="backToInstance()">
              <i class="toolbar-button ng-scope glyphicon glyphicon-remove" data-toggle="tooltip" title="关闭窗口"></i>
            </button>
          </div>
        </div>
        <div class="text-center">
          <div class="help-container fixed">
            <div>
              <div class="help-text">
                <div class="description">
                  {{ 'TASK.HELP.NO-ASSIGNEE' | translate }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div
      ng-if="activeTab == 'details' && model.task != null && model.task != undefined && hasDetails() == false && !model.involvementSummary.loading && !model.contentSummary.loading && !model.commentSummary.loading && !model.subTaskSummary.loading"
    >
      <div
        ng-if="model.task.assignee || (model.task.assignee == null || model.task.assignee == undefined) && (model.task.memberOfCandidateGroup || model.task.memberOfCandidateUsers || (model.task.initiatorCanCompleteTask && model.task.processInstanceStartUserId == ('' + account.id)))"
      >
        <p class="no-form">{{ 'PROCESS.MESSAGE.NO-FORM-PROCESS' | translate }}</p>
      </div>
      <div
        class="section"
        ng-if="(model.task.assignee == null || model.task.assignee == undefined) && (!model.task.memberOfCandidateGroup && !model.task.memberOfCandidateUsers && !(model.task.initiatorCanCompleteTask && model.task.processInstanceStartUserId == ('' + account.id)))"
      >
        <div class="top-buttons" ng-if="taskId && !rev" ng-controller="RenderFormController">
          <div class="btn-group pull-right">
            <div class="btn-toolbar pull-right">
              <button title="关闭窗口" class="btn btn-inverse" ng-click="closeModelWindow()">
                <i
                  class="toolbar-button ng-scope glyphicon glyphicon-remove"
                  data-toggle="tooltip"
                  title="关闭窗口"
                ></i>
              </button>
            </div>
          </div>
        </div>
        <!-- 流程实例详情关闭按钮 -->
        <div class="top-buttons" ng-if="rev" ng-controller="TaskDetailController">
          <div class="btn-toolbar pull-right">
            <button title="关闭窗口" class="btn btn-inverse" ng-click="backToInstance()">
              <i class="toolbar-button ng-scope glyphicon glyphicon-remove" data-toggle="tooltip" title="关闭窗口"></i>
            </button>
          </div>
        </div>
        <div class="text-center">
          <div class="help-container fixed">
            <div>
              <div class="help-text">
                <div class="description">
                  {{ 'TASK.HELP.NO-ASSIGNEE' | translate }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
